import { useI18n } from '@/hooks/web/useI18n' // 使用 useI18n 来获取翻译
// import { i18n } from "@/plugins/vueI18n"  // 如果你有其他方式的 i18n 配置，也可以导入
import ApprovalDesigner from '@/components/Designer/ApprovalDesigner.vue'
// import FormCreateDesigner from "@/components/Designer/form/formDesigner/FormCreateDesigner.vue";
import FormDesigner from '@/components/Designer/form/FormDesigner.vue'
import FormFillOut from "@/components/Designer/form/FormFillOut.vue";
import FormDataList from "@/components/Designer/form/FormDataList.vue";
// import CenterForm from "@/views/res/ResCenter/CenterForm.vue";
import DashBoardDesiger from "@/components/Designer/dashboard/DashBoardDesiger.vue";
import PageDesigner from "@/components/Designer/page/src/PageDesigner.vue";
import AppDesigner, { openDesigner } from "@/components/Designer/app/src/AppDesigner.vue"; 
import ApiDesigner from '@/components/Designer/Interface/src/ApiDesigner.vue';


export const methodMap = () => {


}

export interface OperItem{
  icon: string,
  size: string,
  text: string,
}

// ... existing code ...
export const getComponentProps = (item: OperItem, row: CenterVO) => {
  // 默认属性
  const defaultProps = {
    link: true,
    type: 'info',
    operItem:item,
    resModel:row
  }

  // 如果item中有props属性，则合并属性
  if (item.props) {
    return {
      ...defaultProps,
      ...item.props
    }
  }

  return defaultProps
}
/**
 * 获取操作按钮集合
 * @returns {object} 操作按钮集合
 */
export const getResActBtns = () => {
  const { t } = useI18n()  // 在函数内部获取 t()，确保只在组件中执行

  return {
    /**
     * 编辑
     */
    edit: 1,
    /**
     * 删除
     */
    del: 2,
    /**
     * 新增 子项
     */
    addSubItem: {
      icon: 'ep:folder-add',
      size: 'small',
      text: t('res.appList.appBtnList.addSubItem'),
      // cmp: AddSubItemCmp,
      methodName: 'handleAdd'
    },

    appDeploy: {
      icon: 'ep:money',
      size: 'small',
      text: t('res.appList.appBtnList.deploy')
    },
    appDesigner: {
      // icon: 'fa-solid:tools',
      // text: t('res.appList.appBtnList.designer'),
      // size: 'small',
      // cmp: AppDesigner,
      component: AppDesigner,
      props: { // 可选，指定组件的属性
        
        size:'small',
        icon: 'fa-solid:tools', 
        text: t('res.appList.appBtnList.designer')
        // ... 其他属性
      }
    },
    /**
     * 设计
     */
    designer: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      cmp: ApprovalDesigner
    },
    /**
     * 表单设计
     */
    formDesigner: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      cmp: FormDesigner
    },
    pageDesigner: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      cmp: PageDesigner
    },  
    apiDesigner: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      cmp: ApiDesigner
    },
    /**
     * 表单设计
     */
    dashboardDesigner: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      cmp: DashBoardDesiger
    },
    formFillOut: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.formFillOut'),
      cmp: FormFillOut
    },
    formDataList: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.formDataList'),
      cmp: FormDataList
    },
    resourceDesigner: {
      icon: 'fa-solid:tools',
      size: 'small',
      text: t('res.appList.appBtnList.designer'),
      methodName: 'handleAppDeskTop'
    },
    /**
     * 预览
     */
    preview: {
      icon: 'fa-solid:eye',
      size: 'small',
      text: t('res.appList.appBtnList.preview'),
      type: 'ActionProcPreview',
      methodName: 'handlePreview'
    },
    /**
     * 授权
     */
    auth: {
      icon: 'el-icon-view',
      size: 'small',
      text: t('res.appList.appBtnList.auth'),
      type: 'ActionProcStartAuth',
      methodName: 'handleAuth'
    },
    copy: {
      icon: 'el-icon-circle-plus-outline',
      size: 'small',
      text: t('res.appList.appBtnList.copy'),
      methodName: 'handleCopy'
    },
    overview: {
      icon: 'el-icon-circle-plus-outline',
      size: 'small',
      text: t('res.appList.appBtnList.preview'),
      methodName: 'handleOverview'
    },
    /**
     * 更多
     */
    more: {
      icon: 'el-icon-circle-plus-outline',
      size: 'small',
      text: t('res.appList.appBtnList.more'),
      type: 'ActionProcessMore',
      methodName: 'handleMore'
    }
  }
}
